from processing.model.component import Component
from processing.shape.static_shape import StaticShape
from processing.shape.drawers import CircleDrawer
from processing.shape.color import color, light
from random import randint


class Instruction(Component):
    
    def __init__(self, x=0, y=0):
        Component.__init__(self)
        self.x = x
        self.y = y
        self.__size = 16
        self.dx = randint(0, 14) - 9
        self.dy = randint(0, 14) - 9
        
    def on_added(self):
        self.render  = StaticShape(self, CircleDrawer,  self.sizes, [color.red, light.red])
  
  
    def update(self):
        self.x += self.dx
        self.y += self.dy
        self.size -= 1
        if(self.size < 4):
            self.destroy()
        else:
            self.render.sizes = self.sizes
            self.render.update()
        
    def draw(self):
        self.render.draw()
          
    @property
    def sizes(self):
        return [self.size, self.size - 2]
  
    @property
    def size(self):
        return self.__size

    @size.setter
    def size(self, value):
        self.__size = value

  
    
        